package com.lrkj.smartservice.controller;

import java.util.List;

import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.smartservice.domain.SlideData;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.smartservice.service.ISlideDataService;

/**
 * 轮播列分类Controller
 *
 * @author yajun_ren
 * @date 2021-04-02
 */
@RestController
@RequestMapping("/smartservice/slideData")
public class SlideDataController extends BaseController
{
    @Autowired
    private ISlideDataService slideDataService;

    /**
     * 查询轮播列分类列表
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideData:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlideData slideData)
    {
        startPage();
        List<SlideData> list = slideDataService.selectSlideDataList(slideData);
        return getDataTable(list);
    }

    /**
     * 导出轮播列分类列表
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideData:export')")
    @Log(title = "轮播列分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SlideData slideData)
    {
        List<SlideData> list = slideDataService.selectSlideDataList(slideData);
        ExcelUtil<SlideData> util = new ExcelUtil<SlideData>(SlideData.class);
        return util.exportExcel(list, "slideData");
    }

    /**
     * 获取轮播列分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideData:query')")
    @GetMapping(value = "/{slideDataId}")
    public AjaxResult getInfo(@PathVariable("slideDataId") String slideDataId)
    {
        return AjaxResult.success(slideDataService.selectSlideDataById(slideDataId));
    }

    /**
     * 新增轮播列分类
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideData:add')")
    @Log(title = "轮播列分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlideData slideData)
    {
        return toAjax(slideDataService.insertSlideData(slideData));
    }

    /**
     * 修改轮播列分类
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideData:edit')")
    @Log(title = "轮播列分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlideData slideData)
    {
        return toAjax(slideDataService.updateSlideData(slideData));
    }

    /**
     * 删除轮播列分类
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideData:remove')")
    @Log(title = "轮播列分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{slideDataIds}")
    public AjaxResult remove(@PathVariable String[] slideDataIds)
    {
        return toAjax(slideDataService.deleteSlideDataByIds(slideDataIds));
    }

    /**
     * 根据轮播类型查询列表信息
     */
    @GetMapping(value = "/type/{slideType}")
    public AjaxResult dictType(@PathVariable String slideType)
    {
        return AjaxResult.success(slideDataService.selectSlideDataByType(slideType));
    }
}
